home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2003 #8 / K-CD-8-2003.ISO / Eraser / EraserSetup.exe / {app} / Examples / Delphi / form1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2002-12-08  |  2.5 KB  |  87 lines

  1. unit form1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, menus, extctrls, buttons, clipbrd;
  6. type
  7.   TForm1Cls = class(TForm)
  8.     Erase: TButton;
  9.     FileName: TEdit;
  10.     Label1: TLabel;
  11.     procedure Erase_Click(Sender: TObject);
  12.   private
  13.   public
  14.   end;
  15. var
  16.   Form1Cls: TForm1Cls;
  17. implementation
  18. uses eraserdll;
  19. {$R *.dfm}
  20.  
  21. procedure TForm1Cls.Erase_Click(Sender: TObject);
  22. var
  23.   Bytes: array[0..2] of Integer;
  24.   Context: Integer;
  25.   xResult: Integer;
  26.   FName:pchar;
  27. begin
  28.      //' variables
  29.       Context := 0;
  30.   try
  31.     try
  32.      //' initialize library
  33.       xResult := eraserInit;
  34.       if (eraserError(xResult)) then begin
  35.         Label1.caption := 'Error: eraserInit returned ' + IntToStr(xResult);
  36.         exit;
  37.       end;
  38.      //' create context
  39.       xResult := eraserCreateContext(Context);
  40.       if (eraserError(xResult)) then begin
  41.         Label1.caption := 'Error: eraserCreateContext returned ' + IntToStr(xResult);
  42.         exit;
  43.       end;
  44.      //' set data type
  45.       xResult := eraserSetDataType(Context, ERASER_DATA_FILES);
  46.       if (eraserError(xResult)) then begin
  47.         label1.caption := 'Error: eraserSetDataType returned ' + IntToStr(xResult);
  48.         exit;
  49.       end;
  50.      //' add files to erase
  51.      fName :=pchar(FileName.text);
  52.       xResult := eraserAddItem(Context,fname,length(FileName.text));
  53.       if (eraserError(xResult)) then begin
  54.         label1.caption := 'Error: eraserAddItem returned ' + IntToStr(xResult);
  55.         exit;
  56.       end;
  57.      //' erase
  58.       xResult := eraserStartSync(Context);
  59.       if (eraserError(xResult)) then begin
  60.         label1.caption := 'Error: eraserStartSync returned ' + IntToStr(xResult);
  61.         exit;
  62.       end;
  63.      //' done erasing, query some statistics
  64.       label1.caption := 'File erased.';
  65.      //' the second parameter is a 64-bit value, thus passing array ByRef
  66.       xResult := eraserStatGetArea(Context, Bytes[1]);
  67.       if (eraserOK(xResult)) then begin
  68.         label1.caption := label1.caption + ' (' + IntToStr(Bytes[1]) + ' bytes)';
  69.       end;
  70.     except
  71.      //' handle error
  72.     end;
  73.   finally
  74.      //' show Erasing Report
  75.     xResult := eraserShowReport(Context, Application.Handle);
  76.     if (eraserError(xResult)) then begin
  77.       label1.caption := label1.caption + ' Oops, eraserShowReport returned ' + IntToStr(xResult);
  78.     end;
  79.      //' destroy context
  80.     xResult := eraserDestroyContext(Context);
  81.      //' clean up library
  82.     xResult := eraserEnd;
  83.   end;
  84. end;
  85. end.
  86.  
  87.